﻿@using Webdiyer.WebControls.Mvc;
@model PagedList<Magicodes.WeiChat.Data.Models.CMS.Article_Manage>

@{
    ViewBag.Title = "文章管理";
}

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-9">
        <h2>@ViewBag.Title</h2>
        <ol class="breadcrumb">
            <li>
                <a href="/">主页</a>
            </li>
            <li class="active">
                <strong>@ViewBag.Title</strong>
            </li>
        </ol>
    </div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <hr style="margin:2px 2px 10px 2px;" />
                    <div class="row">
                        <div class="col-sm-6">
                            @using (Html.BeginForm("Index", @Request.RequestContext.RouteData.GetRequiredString("controller"), FormMethod.Get))
                            {
                                <div class="input-group">
                                    <div class="col-sm-6" style="padding-right:5px !important">
                                        @Html.TextBox("q", ViewBag.q as string, new { @placeholder = "请输入关键字", @class = "input-sm form-control" })
                                    </div>
                                    <div class="col-sm-6" style="padding:0px !important">
                                        @Html.DropDownList("columnId", ViewBag.select as SelectList, "--请选择所属栏目--", new { @class = "input-sm form-control" , @style = "padding: 0 0 0 0;padding - left:5px;" })
                                    </div>
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</button>
                                    </span>
                                </div>
                            }
                        </div>
                        <a class="btn btn-primary btn-sm" href="@Url.Action("Create")" id="btnAdd"><i class="fa fa-plus"></i>&nbsp;新建</a>
                        <a class="btn btn-warning btn-sm" id="btnDelete" data-action="Delete" data-comfirmmessage="确定删除所选内容么？"><i class="fa fa-remove"></i>&nbsp;批量删除</a>
                    </div>
                    <div class="row">
                        <table class="table table-striped table-bordered table-hover" style="overflow-x:scroll">
                            <tr>
                                <th>
                                    <input type="checkbox" name="checkAll" id="chkCheckAll" class="i-checks" />
                                </th>

                                <th>
                                    @Html.DisplayNameFor(model => model.Title)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.Autor)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.Release_Time)
                                </th>
                                <th>操作</th>
                            </tr>
                            @if (Model.Count == 0)
                            {
                                <tr>
                                    <td colspan="5" style="text-align:center;">
                                        <label>没有数据</label>
                                    </td>
                                </tr>
                            }
                            else
                            {
                                foreach (var item in Model)
                                {
                                    <tr>
                                        <td>
                                            <input type="checkbox" name="ids" class="i-checks" value="@(item.Id)" />
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.Title)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.Autor)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.Release_Time)
                                        </td>
                                        <td>
                                            <div class="btn-group">
                                                <a class="btn btn-white" href="@Url.Action("Edit", new { id = item.Id })">修改</a>
                                                <a class="btn btn-white delete" data-id="@item.Id">删除</a>
                                            </div>
                                        </td>
                                    </tr>
                                }
                            }
                        </table>
                    </div>
                    <div class="row">
                        @Html.Partial("_BootStrapPager", Model)
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section Styles {
    <style type="text/css">
        .input-sm{
            height:33px !important;
        }
    </style>
    @Styles.Render("~/Content/plugins/iCheck/iCheckStyles")
}
@section Scripts {
    @Scripts.Render("~/plugins/iCheck")
    <script type="text/javascript">
        $(function () {
            mwc.bs.init();
            $('a.btn.delete').on('click', function () {
                var id = $(this).data('id');
                mwc.message.confirm("确定要删除么？", function (result) {
                    if (result) {
                        mwc.restApi.delete({
                            url: '/Article_Manage/Delete',
                            data: { id: id },
                            success: function (data) {
                                mwc.notify.success(data.Message);
                                location.reload();
                            }
                        });
                    }
                });
            });
        });
    </script>
}

